<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section A.10.&nbsp; Chapter 10</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-APP-A-SECT-9.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-APP-A-SECT-11.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><TD valign="top"><a name="learnphpmysql-APP-A-SECT-10"></a>
<h3 id="title-IDAZF2EF" class="docSection1Title">A.10. Chapter 10</h3>
<dl class="docList">
<dt><br><p><span class="docPubcolor"><span class="docEmphStrong">Solution to Question 10-1</span></span></p></dt>
<dd><p class="docList">The super global variable <tt>$_SERVER['PHP_SELF']</tt> always returns the name of the running PHP script. You can rename a script containing the global variable, and your code automatically uses the new script name to process the results.</p></dd>

<dt><br><p><span class="docPubcolor"><span class="docEmphStrong">Solution to Question 10-2</span></span></p></dt>
<dd><p class="docList">The code to create a username and password form that processes the values is written as follows:</p>
<pre>
&lt;?php
echo ('&lt;form action="'.$_SERVER["PHP_SELF"].'" method="GET"&gt;');
echo ('
&lt;label&gt;Username:&lt;input type="text" name="username" size="10" maxlength="30" /&gt;&lt;/label&gt;
&lt;br&gt;
&lt;label&gt;Password:&lt;input type="text" name="password" size="10" maxlength="30" /&gt;&lt;/label&gt;
&lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;');
?&gt;
</pre><br>

</dd>

<dt><br><P><span class="docPubcolor"><span class="docEmphStrong">Solution to Question 10-3</span></span></p></dt>
<dd><p class="docList">In order to also display the username and password upon submission, specify:</p>
<pre>
&lt;?php
//Get the username and passowrd from the GET global array
$username = $_GET["username"];
$password = $_GET["password"];
//determine if this is after the form's been submitted
if (!empty($username)){
  //display the values from the submission
  echo ("Username: $username&lt;br&gt;");
  echo ("Password: $password&lt;br&gt;");
}
else {
//display the form
echo ('&lt;form action="'.$_SERVER["PHP_SELF"].'" method="GET"&gt;');
echo ('
&lt;label&gt;Username:&lt;input type="text" name="username" size="10" maxlength="30" /&gt;&lt;/label&gt;
&lt;br&gt;
&lt;label&gt;Password:&lt;input type="text" name="password" size="10" maxlength="30" /&gt;&lt;/label&gt;
&lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;');
}
?&gt;
</pre><BR>

</dd>

<dt><BR><p><span class="docPubcolor"><span class="docEmphStrong">Solution to Question 10-4</span></span></P></dt>
<dd><p class="docList">To select only author names starting with an "A", use the following query:</p>
<pre>
SELECT * FROM authors WHERE author LIKE 'A%'`
</pre><br>

</dd>
</dl>

<a href="11011536.html"><img src="images/pixel.jpg" alt="" width="1" height="1" border="0"></a></TD></TR></table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-APP-A-SECT-9.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-APP-A-SECT-11.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html>